
from deepdiff import DeepDiff
template_json={"key1":41,"key2":{"nested1":"value","nested2":[1,2,3]}}
target_json={"key1":42,"key2":{"nested1":"value","nested2":"[1,2,3]"}}
diff = DeepDiff(template_json,target_json)
changes=diff.get("type_changes",{})
print(changes)

print("abc".isalpha())
print("123".isdigit())

res = "ABC".lower()
print(res)


print(679%26)
print(679//26)

res = set()
res.add(1)
res.add(1)
print(res.pop())


def majorityElement(nums: list[int]) -> int:
        candidate, count = None, 0
        for num in nums:
            if count == 0:
                candidate = num
            count += (1 if candidate == num else -1)
        return candidate
list1 = [2,2,1,3,5]
print(majorityElement(list1))


def titleToNumber(columnTitle):
    ret = 0
    for i in columnTitle:
        ret = ret * 26 + ord(i) - 64
    return ret
print(titleToNumber("ZZ"))


class Solution:
    def plusOne(self, digits: list) -> list:
        digits = digits[::-1]
        for i in range(0, len(digits)):
            if digits[i] == 9 and i == len(digits) - 1:
                digits[i] = 0
                digits.append(1)
            elif digits[i] == 9:
                digits[i] = 0
            else:
                digits[i] = digits[i] + 1
                break
        return digits[::-1]

solution = Solution()
print(solution.plusOne([1, 2, 3]))  # 输出: [1, 2, 4]
print(solution.plusOne([8, 1, 9]))



# 会超时的递归代码
class Solution:
    def climbStairs(self, n: int) -> int:
        def dfs(i: int) -> int:
            if i <= 1:  # 递归边界
                return 1
            return dfs(i - 1) + dfs(i - 2)
        return dfs(n)

solution = Solution()
print(solution.climbStairs(5))

class Solution2:
    def climbStairs(self, n: int) -> int:
        def dfs(i:int,memo) -> int:
            if i == 0 or i == 1:
                return 1
            if memo[i] == -1:
                memo[i] = dfs(i-1,memo) + dfs(i-2,memo)
            return memo[i]
        return dfs(n,[-1]*(n+1))
solution2 = Solution2()
print(solution2.climbStairs(5))



print([[1]*(i+1) for i in range(0,5)])


# def cal(x,n):
#     res = 1
#     for i in range(0,n):
#         res = res*x
#     return res
# print(cal(3,3))

def cal_2(x):
    res = 1
    for i in range(1,x+1):
        res = res*i
    return res
print(cal_2(5))





